﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>生日提醒</title>
    <script src="../../Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../../Content/JS/layer-v1.7.1/layer/layer.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .BirthdayNav1{ margin-left:50px; margin-top:20px;}
        #sendEmail,#sendMsg,#excel,#exit{ margin-left:50px;}
        .BirthdayNav2{  margin-top:30px; width:94%; margin-left:auto; margin-right:auto; overflow:scroll;}
        .BirthdayTabel th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px; }
        .table-first-tr{background:url(../../images/thead.gif) left 12px repeat-x; background:#B5B5B5;  font-weight:bold;  padding:10px; border-bottom:solid 1px #CDCDCD;}
        .BirthdayTabel{ border-color:#1C1C1C; height: 100%; width:100%;overflow:scroll;text-align:center; border-collapse:collapse; border-spacing:0;}
        .pager{ margin-left:30%;  padding-top:20px; }
    </style>
</head>
<body class="main" >
    <div class="AllWebTopDiv">
        <div class="path">
             <div class="nav">
               <a href="#">生日提醒</a>
             </div>
        </div>
       <div class="content">
       <div class="BirthdayNav1">
         提醒天数： <input type="text" name="Number" id="Number"   class="Line" value="100"/>
          <input  type="button" id="search" value="搜索" class="button2" onclick="search();" />
          <input  type="button" id="sendEmail" value="邮件群发" class="button2"/> 
          <input  type="button" id="excel" value="Excel导出" class="button2" onclick="daochu()"/>
          <input  type="button" id="exit" value="退出" onclick="closeWindows();"  class="button2"/>
       </div>
       <div class="BirthdayNav2">
      <table id="ShowData" border="1"  class="BirthdayTabel">

    </table>      
        <div class="pager">
       <input  type="button" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('首页')"style="cursor:pointer"  value="首页" class="button"/>
         <input type="button" value="上一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('上一页')"style="cursor:pointer" class="button"/>
         <input type="button" value="下一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('下一页')"style="cursor:pointer" class="button"/>
         <input type="button" value="末页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('末页')"style="cursor:pointer" class="button"/>
      
       　共 <label id="maxPage">1</label> 页 第 <label id="CurrentPage">1</label> 页
       </div>
  
       </div>
    </div>
    </div>
</body>
</html>
<script type="text/javascript">

     var pageNum=1;
     var pageSize=20;
     var Birthday = document.getElementById("Number").value;
   //搜索
    function search() {

        Birthday = document.getElementById("Number").value;
        var strReg="^\\d+$";
        var re=new RegExp(strReg);
        if (Birthday.match(re)!=null) {
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadData","BirthdayRemind") %>",
            data:"pageSize="+pageSize+"&Birthday="+Birthday+"",
            cache:false,
            success:function(html)
            {
    
                $("#ShowData").html(html);
                newPage("首页");
            }
           })
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","BirthdayRemind") %>",
            data:"pageSize="+pageSize+"&Birthday="+Birthday+"",
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        })
        }
        else {
            alert("应为正整数");
        }
    }
    


      $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadData","BirthdayRemind") %>",
            data:"pageSize="+pageSize+"&Birthday="+Birthday+"",
            cache:false,
            success:function(html)
            {
    
                $("#ShowData").html(html);
                newPage("首页");
            }
           })
               $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","BirthdayRemind") %>",
            data:"pageSize="+pageSize+"&Birthday="+Birthday+"",
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        })

        function newPage(sa)
        {
           var CurrentPage= $("#CurrentPage").html();
             var maxPage=$("#maxPage").html();
           
            maxPage=parseInt(maxPage);
            
            
            if(sa=="首页")
            {
                pageNum=1;
               document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="下一页")
            {
                 if(CurrentPage>=maxPage)
                {
                     layer.alert("已是最大页数");
                    return;
                }
                pageNum++;
                document.getElementById("CurrentPage").innerHTML=pageNum;
               
            }
            if(sa=="上一页")
            {
                 if(CurrentPage==1)
            {
                layer.alert("已是最小页数");
                return;
            } 
                pageNum--;
                document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="末页")
            {
                pageNum=maxPage;
                 document.getElementById("CurrentPage").innerHTML=pageNum;
            }
              $.ajax({
                type:"POST",
                url:"<%:Url.Action("newPage","BirthdayRemind") %>",
                data:"pageNum="+pageNum+"&pageSize="+pageSize+"&Birthday="+Birthday+"",
                cache:false,
                success:function(html)
                {
                $("#ShowData").html(html); 
                }
            })
        }
          //导出
      function daochu(){
       Birthday = document.getElementById("Number").value;
        var strReg="^\\d+$";
        var re=new RegExp(strReg);
        if (Birthday.match(re)!=null) {
         window.open('/BirthdayRemind/birthdayToExcel?birthday='+Birthday);
            }
    
      }
         //关闭窗口
       function closeWindows()
    {
     window.location.href = "/Loading/Index/?src=/Desktop/Index/";
    }
</script>
